import "../../../just/libafl.just"
FUZZER_NAME := "tinyinst_simple"

set windows-shell := ["cmd.exe", "/c"]
set unstable

[linux]
harness:
    clang test/test.cpp -o test.exe

[windows]
harness:
    cl test\test.cpp -o test.exe


fuzzer: 
    cargo build --profile {{PROFILE}}

run: harness fuzzer
    cargo run --profile {{PROFILE}}

[linux]
test: harness fuzzer
    #!/bin/bash
    cp {{TARGET_DIR}}/{{PROFILE_DIR}}/tinyinst_simple .
    echo "Running tests"
    timeout 5s ./tinyinst_simple || true
    # corpus_discovered folder exists and is not empty
    if [ -d "corpus_discovered" ] && [ -n "$(ls -A corpus_discovered)" ]; then
        echo "Fuzzer works!"
    else
        exit 1
    fi

[windows]
test: harness fuzzer
    copy .\target\{{PROFILE_DIR}}\tinyinst_simple.exe .
    start .\tinyinst_simple.exe
    ping -n 10 127.0.0.1>NUL && taskkill /im tinyinst_simple.exe /F
    dir /a-d corpus_discovered && (echo Files exist) || (exit /b 1337)